home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
docs
/
ippon
/
ver
/
050
/
ippon050.lzh
/
maketbl.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-07
|
2KB
|
105 lines
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SPEED_MAX 32
double speed[SPEED_MAX] =
{0.50, 0.60, 0.70, 0.80, 0.90,
1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90,
2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80, 2.90,
3.00, 3.10, 3.20,
4.00, 5.00, 6.00, 7.00};
typedef struct {
signed int x, y;
} VECTOR;
unsigned char pstable[256][256];
VECTOR xytable[SPEED_MAX][256];
unsigned char rndtable[256];
void usage (void)
{
printf (
"IPPON.X 用テーブルを作成する maketbl.x ver0.01\n"
" programmed by Mitsuky <FreeSoftware>\n"
"以下のテーブルを作成します\n"
" TBL/PSTABLE.DAT : 自機サーチテーブル\n"
" TBL/RNDTABLE.DAT : 乱数テーブル\n"
" TBL/XYTABLE.DAT : sin,cos テーブル\n"
"角度関係のは全て1周=256段階で、右向きが0、下向きが64となっております\n"
);
}
int maketable (void)
{
int i, j;
FILE *fp;
printf ("データテーブルを作成します。\n");
printf ("少々時間が掛かります。申し訳ありません。\n"
"( arctan を 256x256 個計算しています。)\n");
for (i = 0; i < 256; i++) {
printf ("%3d/256\x1b[0J\n\x0b", i + 1);
for (j = 0; j < 256; j++) {
pstable[i][j] = (unsigned char) (atan ((double) j / (double) i) * 256.0 / 2.0 / M_PI);
}
}
fp = fopen ("TBL/PSTABLE.DAT", "wb");
if (fp == NULL) {
printf ("TBL/PSTABLE.DAT が書き込めません\n");
exit (-1);
}
fwrite (pstable, 256 * 256, sizeof (unsigned char), fp);
fclose (fp);
for (i = 0; i < 256; i++)
rndtable[i] = (unsigned char) ((rand () / 4) & 255);
fp = fopen ("TBL/RNDTABLE.DAT", "wb");
if (fp == NULL) {
printf ("TBL/RNDTABLE.DAT が書き込めません\n");
exit (-1);
}
fwrite (rndtable, 256, sizeof (unsigned char), fp);
fclose (fp);
for (i = 0; i < SPEED_MAX; i++) {
for (j = 0; j < 256; j++) {
xytable[i][j].x = (signed int) (cos (2.0 * M_PI * (long) j / 256.0) * 65536.0 * speed[i]);
xytable[i][j].y = (signed int) (sin (2.0 * M_PI * (long) j / 256.0) * 65536.0 * speed[i]);
}
}
fp = fopen ("TBL/XYTABLE.DAT", "wb");
if (fp == NULL) {
printf ("TBL/XYTABLE.DAT が書き込めません\n");
exit (-1);
}
fwrite (xytable, 256 * SPEED_MAX, sizeof (VECTOR), fp);
fclose (fp);
printf ("\n終了しました。\n");
return (0);
}
int main (int argc, char *argv[])
{
if (argc != 1) {
usage ();
return (-1);
}
maketable ();
return (0);
}